package com.mybatiscore.jiaocheng.d03mybatis查询专项;

import com.mybatiscore.Mapper.StudentMapper;
import com.mybatiscore.POJO.Student;
import com.mybatiscore.Util.SqlSessionUtil;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

import java.util.List;

public class d03resultMap结果映射 {
    /*
     resultMap:指定数据库表的名与java类属性名
        type:指定POJO的类名
        id:resultMap的标识

    <resultMap id="studentResultMap" type="Student">
        <id property="id" column="id"/>
        <result property="sex" column="sex"/>
        <result property="age" column="age"/>
        <result property="name" column="name"/>
        <result property="birth" column="birth"/>
        <result property="heightT" column="height_t" javaType="String" jdbcType="DOUBLE">
    </resultMap>
     */
    @Test
    public void resultMap(){
        SqlSession sqlSession = SqlSessionUtil.openSession();
        StudentMapper mapper = sqlSession.getMapper(StudentMapper.class);
        List<Student> students = mapper.selectAllresultMap();
        students.forEach(s-> System.out.println(s));
        sqlSession.close();
    }
}
